<template>
	<view class="myyongjin">
		<view class="head-card">
			<view class="info-1">
				<text>奖励余额</text>
			</view>
			<view class="info-2">
				<text>{{ info.money || '0.00' }}</text>
			</view>
			<u-divider lineColor="#fff" style="margin: 0"></u-divider>
			<view class="info-3">
				<view class="info-1">
					<text>奖励总和</text>
					<text>￥{{ info.zong_money || '0.00' }}</text>
				</view>
				<view class="divider-y"></view>
				<view class="info-1">
					<text>累积提现</text>
					<text>￥{{ info.tixian || '0.00' }}</text>
				</view>
			</view>
		</view>

		<view class="container">
			<view class="u-tabs-box">
				<u-tabs
					:list="tabList"
					@click="cTab"
					:scrollable="false"
					itemStyle="height: 88rpx;font-weight: bold;"
					inactiveStyle="font-size: 24rpx;"
					lineColor="#E54E4E"
				></u-tabs>
			</view>
			<view class="listbox">
				<j-yongJinList :list="list"></j-yongJinList>
				<u-loadmore :status="status" />
			</view>
		</view>

		<u-popup round="8rpx" :closeable="true" :show="txpop" @close="txpop = false" mode="center">
			<view class="txpopbox" v-if="isqr">
				<view class="title">确认提现</view>

				<view class="content">
					<view class="tbox">
						<text>提现</text>
						<text>{{ form.money }}</text>
					</view>
					<view class="bbox">
						<view class="row">
							<text>服务费</text>
							<text>￥0.50</text>
						</view>
						<view class="row">
							<text>费率</text>
							<text>8%</text>
						</view>
					</view>
				</view>
				<button :disabled="tx_loading" @click="tixian">确认</button>
			</view>
			<view class="txpopbox" v-else>
				<view class="title">提现</view>
				<view class="tip">
					<text>提现到</text>
					<text>微信零钱</text>
				</view>

				<view class="inputbox">
					<view class="row">
						<text>提现积分 积分比例1/100</text>
					</view>
					<view class="inpbox">
						<label for="">￥</label>
						<input :focus="true" v-model="form.money" type="digit" />
					</view>
					<view class="btip">
						<text>当前可提现余额￥{{ info.money }}元，</text>
						<text @click="form.money = info.money">全部提现</text>
					</view>
				</view>
				<button @click="tixian">提现</button>
			</view>
		</u-popup>

		<!-- <footer-btn
			text="前往兑换商品"
			@submit="submit"
			twoBtn
			oneText="提现到微信"
			twoText="提现到银行卡"
			:btnStyle="{
				color: '#53361E',
				background: 'linear-gradient(135deg, #ffe9cc 0%, #f2cea1 100%)'
			}"
		></footer-btn> -->
		<footer-btn
			text="提现到微信"
			@submit="submit"
			:btnStyle="{
				color: '#53361E',
				background: 'linear-gradient(135deg, #ffe9cc 0%, #f2cea1 100%)'
			}"
		></footer-btn>
		<!-- <footer-btn
			text="提现到银行卡"
			@submit="submit"
			:btnStyle="{
				color: '#53361E',
				background: 'linear-gradient(135deg, #ffe9cc 0%, #f2cea1 100%)'
			}"
		></footer-btn> -->
	</view>
</template>

<script>
import API from '@/common/api';
import { get_userInfo } from '@/common/common_fun';
export default {
	name: 'myyongjin',
	data() {
		return {
			isqr: false,
			txpop: false,
			tx_loading: false,
			status: '',
			tabList: [
				{
					name: '全部',
					val: -1
				},
				{
					name: '收入',
					val: 0
				},
				{
					name: '支出',
					val: 3
				}
			],
			info: {},
			list: [],
			paging: {
				page: 1,
				pagenum: 10
			},
			user_info: {},
			form: {
				money: ''
			},
			type: -1
		};
	},
	onLoad() {
		this.reset();
		this.init();
	},
	onShow() {
		get_userInfo((data) => {
			this.user_info = data;
		});
	},
	onReachBottom() {
		if (this.status === 'nomore') return;
		this.init();
	},
	methods: {
		submit(flag) {
			this.isqr = false;
			this.txpop = true;
			// this.toNav(`tixian/tixian`);
			return;
			switch (flag) {
				case 1:
					this.isqr = false;
					this.txpop = true;
					break;
				case 2:
					this.toNav(`tixian/tixian`);
					break;
				default:
					break;
			}
		},
		tixian() {
			if (!parseFloat(this.form.money)) {
				this.msg('请输入提现金额');
				return;
			}

			if (this.isqr) {
				let params = {
					money: this.form.money,
					type: 1
				};
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				this.tx_loading = true;
				this.$http.getJson('money_tixian', params).then((res) => {
					uni.hideLoading();
					this.tx_loading = false;
					this.msg(res.message, () => {
						this.reset();
						this.init();
						this.txpop = false;
						this.form.money = '';
					});
				});
			}

			this.isqr = true;
		},
		cTab(e) {
			this.reset();
			this.type = e.val;
			this.init();
		},
		reset() {
			this.paging.page = 1;
			this.list = [];
		},
		init() {
			this.status = 'loading';
			API.getJson('users_yongjinRecord', { type: this.type, ...this.paging }).then((res) => {
				const { code, data, message } = res;
				if (code === 1) {
					this.info = res;
					if (data.length !== 0) this.list = this.list.concat(data);
					if (this.paging.pagenum === data.length) {
						this.paging.page += 1;
						this.status = 'loadmore';
					} else {
						this.status = 'nomore';
					}
					console.log('users_yongjinRecord', res);
				}
			});
		}
	}
};
</script>

<style lang="less" scoped>
.myyongjin {
	.txpopbox {
		width: 638rpx;
		padding: 40rpx 50rpx;
		background: #ffffff;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		.content {
			.tbox {
				.flex-center-y();
				padding: 10rpx 0 58rpx;
				text:nth-of-type(1) {
					font-size: 34rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #222222;
				}
				text:nth-of-type(2) {
					margin-top: 10rpx;
					font-size: 72rpx;
					font-family: PingFang SC-Heavy, PingFang SC;
					font-weight: 800;
					color: #222222;
					&:before {
						content: '￥';
						font-size: 52rpx;
					}
				}
				border-bottom: 2rpx solid #eeeeee;
			}
			.bbox {
				padding: 42rpx 0 62rpx;
				.row + .row {
					margin-top: 24rpx;
				}
				.row {
					.flex-between();
					text {
						font-size: 24rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #adadad;
					}
				}
			}
		}
		& > button {
			width: 538rpx;
			height: 64rpx;
			background: #07c160;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			font-size: 32rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #ffffff;
		}

		.title {
			text-align: center;
			font-size: 34rpx;
			font-family: PingFang SC-Heavy, PingFang SC;
			font-weight: 800;
			color: #222222;
			padding-bottom: 50rpx;
		}
		.tip {
			display: flex;
			align-items: center;
			padding: 0 20rpx;
			width: 538rpx;
			height: 80rpx;
			background: #f5f5f5;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			text:nth-of-type(1) {
				margin-right: 18rpx;
				font-size: 28rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #999999;
			}
			text:nth-of-type(2) {
				font-size: 28rpx;
				font-family: PingFang SC-Heavy, PingFang SC;
				font-weight: 800;
				color: #222222;
			}
		}

		.inputbox {
			padding: 50rpx 0;
			.row {
				text {
					font-size: 32rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #222222;
					word-spacing: 1em;
				}
			}

			.inpbox {
				height: 184rpx;
				display: flex;
				align-items: center;
				label {
					font-size: 54rpx;
					font-family: PingFang SC-Heavy, PingFang SC;
					font-weight: 800;
					color: #222222;
				}
				input {
					height: 100rpx;
					font-size: 72rpx;
					font-family: PingFang SC-Heavy, PingFang SC;
					font-weight: 800;
					color: #222222;
				}
			}
			.btip {
				text:nth-of-type(1) {
					font-size: 24rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
				}
				text:nth-of-type(2) {
					font-size: 24rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #f10018;
					.j-active();
				}
			}
		}
	}
	.divider-y {
		width: 1rpx;
		height: 100%;
		margin: 0 24rpx;
		background-color: #f2f2f2;
	}
	.u-tabs-box {
		height: 88rpx;
		background: #ffffff;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
	}
	.container {
		padding: 24rpx 32rpx;
	}
	.listbox {
		padding-top: 24rpx;
	}
	.head-card {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		width: 750rpx;
		height: 248rpx;
		padding: 26rpx 32rpx;
		// background: linear-gradient(135deg, #ffdccb 0%, #e2b89d 100%);

		background: linear-gradient(135deg, #ffe9cc 0%, #f2cea1 100%);
		.info-1 {
			.flex-between();
			font-size: 24rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #53361e;
			text:nth-of-type(1) {
				font-weight: bold;
			}
		}
		.info-2 {
			text:nth-of-type(1) {
				font-size: 56rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #53361e;
				&:before {
					content: '￥';
					font-size: 28rpx;
				}
			}
		}
		.info-3 {
			display: flex;
			.info-1 {
				flex: 1;
			}
		}
	}
}
</style>
